package com.OrderingServer.Controller.seller;

import com.OrderingServer.dto.OrderDTO;
import com.OrderingServer.pojo.OrderDetail;
import com.OrderingServer.pojo.OrderMaster;
import com.OrderingServer.service.IOrderDetailService;
import com.OrderingServer.service.IOrderMasterService;
import com.OrderingServer.utils.Result;
import com.OrderingServer.vo.ResultVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/seller")
public class OrderDetailController {
    @Autowired
    IOrderMasterService orderMasterService;
    @Autowired
    IOrderDetailService orderDetailService;
    @ApiOperation("分页查询所有订单详情信息")
    @GetMapping("/order-detail/selectPage")
    public Result getAllByPage(
                               @RequestParam(defaultValue = "1000")Integer pageSize,
                               @RequestParam Long orderId){
        PageInfo<OrderDetail> pageInfo =orderDetailService.selectPage(pageSize,orderId);
        return   Result.success(pageInfo);
    }
    @PostMapping("/product-info/delete/{orderId}")
    public ResultVO<List<OrderDTO>> cancel (@RequestParam ("openid") String openid,
                                            @PathVariable String orderId)
    {

        orderMasterService.buyercancel(openid,orderId);
        return new ResultVO(0,"成功",null);
    }
}
